package tgc.edu.yzy.service;

import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import tgc.edu.yzy.custom.CommonService;
import tgc.edu.yzy.entity.Teacher;
import tgc.edu.yzy.repository.TeacherRepository;
@Service
public class TeacherService extends CommonService<Teacher, Integer>{
	@Autowired
	private TeacherRepository teacherdao;

	public Teacher findByTcuserAndTcpassword(String username, String password) {
		return teacherdao.findByTcuserAndTcpassword(username,password);
	}
	@Transactional
	public void updatepassword(String password, Integer id) {
		teacherdao.updatePassword(password, id);
		
	}
	public Teacher findById1(Integer id) {
		Optional<Teacher> op=teacherdao.findById(id);
		if(op.isPresent()) {
			return op.get();
		}
		return null;
	}
	
	public Teacher findByTcuser(String tbuser) {
		return teacherdao.findByTcuser(tbuser);
	}
	
}
